﻿using Sustainalytics.Owin.Extensions;
using System;
using System.Diagnostics.CodeAnalysis;
using Topshelf;

namespace Sustainalytics.ComprehensiveESGResearch.UI.Service
{
    [ExcludeFromCodeCoverage]
    public static class Program
    {
        private const string ServiceName = "Sustainalytics.ComprehensiveESGResearch.UI.Service";

        public static void Main()
        {
            HostFactory.Run(x =>
            {
                x.Service<WebAppService>(sc =>
                {
                    sc.ConstructUsing(() => new WebAppService());
                    sc.WhenStarted(s => s.Start<Startup>());
                    sc.WhenStopped(s => s.Stop());
                });

                x.RunAsLocalSystem();

                x.SetServiceName(ServiceName);
                x.SetDisplayName(ServiceName);
                x.SetDescription("Hosts the " + ServiceName.Replace(".", " "));
            });
        }
    }
}
